package com.yidu.qx.dao;

import com.yidu.qx.domain.QxCharacterEntity;
import com.yidu.qx.domain.QxRoleUserEntity;
import com.yidu.qx.utils.Pages;
import org.springframework.orm.hibernate4.HibernateTemplate;

import java.util.List;

/**
 * @program: jurisdiction
 * @description: 角色用户表实现类
 * @author: 张超
 * @create: 2019-09-25 14:04
 */
public class RoleUserDaoImpl implements RoleUserDao {
    private HibernateTemplate hibernateTemplate;

    public HibernateTemplate getHibernateTemplate() {
        return hibernateTemplate;
    }

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }
    @Override
    public void add(QxRoleUserEntity qxRoleUserEntity) {
        hibernateTemplate.save(qxRoleUserEntity);
    }

    @Override
    public void delete(String id) {
        QxRoleUserEntity qxRoleUserEntity=findById(id);
        hibernateTemplate.delete(qxRoleUserEntity);
    }

    @Override
    public void update(QxRoleUserEntity qxRoleUserEntity) {

    }

    @Override
    public List<QxCharacterEntity> findAll(QxRoleUserEntity qxRoleUserEntity, Pages pages) {
        return null;
    }

    @Override
    public QxRoleUserEntity findById(String id) {
        return hibernateTemplate.get(QxRoleUserEntity.class,id);
    }


    @Override
    public Long count(QxRoleUserEntity qxRoleUserEntity) {
        return null;
    }

    @Override
    public List<QxRoleUserEntity> findUserId(String userId) {
        List<QxRoleUserEntity> list= (List<QxRoleUserEntity>) hibernateTemplate.find("from QxRoleUserEntity q where q.qxUserEntity.userId='"+userId+"'");
        return list;
    }
}